/*
  学习目标：组建通信-父传子
*/

import React from 'react';

export default class Parent extends React.Component {
  state = {
    money: 1000,
  };

  handleMakeMoney = () => {
    this.setState({
      money: 1000 + this.state.money,
    });
  };

  render() {
    return (
      <div>
        <h1>{this.state.money}</h1>
        <button onClick={this.handleMakeMoney}>爸爸开始赚钱了</button>
        <Child
          // 1. props传值
          money={this.state.money}
        ></Child>
      </div>
    );
  }
}

class Child extends React.Component {
  render() {
    // 2. 子组件接收props
    return (
      <div>
        <h1>爸爸给我钱了：{this.props.money} </h1>
      </div>
    );
  }
}
